Writing content to a page

Use echo to add content to the constructed page. Add tags to the expression to form HTML elements.

Hello World

Add comments to your code

Use // or /*...*/ to add comments to your code.

Hello World

String types

Use 'single quotes' for literal strings, "double quotes" for variable substitution.

My name is Jill

My name is $name.

Multiple lines 1

Quoted material can span multiple lines in your source code for convenience (remember that on display the browser ignores newlines and whitespace).

I'm having spam spam spam spam spam spam spam baked beans spam spam spam and spam! -Monty Python

Multiple lines 2

The heredoc operator <<< can also be used for multiple lines in your source code for convenience (remember that on display the browser ignores newlines and whitespace).

I'm having spam spam spam spam spam spam spam baked beans spam spam spam and spam! -Monty Python

Multiple lines 3

Multiple line strings can also be assigned to variables using either method.

I'm having spam spam spam spam spam spam spam baked beans spam spam spam and spam! -Monty Python

Multiple lines 3

Multiple line strings can also be assigned to variables using either method.

I'm having spam spam spam spam spam spam spam baked beans spam spam spam and spam! -Monty Python

PHP has classes and objects

Create a Browser object to get the browser type. The Browser class used was downloaded here from GitHub.

Note that files can be included in your source code, and that if statements can be constructed similar to other languages.

The $_SERVER array shows what can be obtainde from the system regarding the browser type.

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

Your browser is version

PHP has for loops

for loops have the same format as Java or C++.

1, 2, 3, 4, 5, 6, 7, 8, 9, 10!

PHP has while loops

while loops have the same format as Java or C++.

1 times 12 is 12
2 times 12 is 24
3 times 12 is 36
4 times 12 is 48
5 times 12 is 60
6 times 12 is 72
7 times 12 is 84
8 times 12 is 96
9 times 12 is 108
10 times 12 is 120
11 times 12 is 132
12 times 12 is 144

PHP has for each loops

for each loops are helpful to go through everything in an array.

Note that the output is also creating list items, one unordered and one ordered. Note that the unset function releases the memory used by the array.

  1. apples
  2. bananas
  3. cherries
  4. durian
  5. elderberry

PHP has many built in functions, including a shuffle function.

Reload the page to shuffle the lists.

  1. cherries
  2. elderberry
  3. durian
  4. apples
  5. bananas